package top.tervest.easyshare.common;

import lombok.Data;
import org.omg.PortableInterceptor.SUCCESSFUL;
import top.tervest.easyshare.common.constant.ResponseMsg;
import top.tervest.easyshare.common.constant.ResponseState;

/**
 *
 * @author ZhangNanNan
 * @create 2019-07-17 14:18
 */
@Data
public class Result {
    private Integer state;
    private String msg;
    private Object data;

    public Result(Integer state, String msg) {
        this.state = state;
        this.msg = msg;
    }

    public Result(Integer state, String msg, Object data) {
        this.state = state;
        this.msg = msg;
        this.data = data;
    }

    public static Result success(){
        return new Result(ResponseState.SUCCESS,ResponseMsg.SUCCESS);
    }

    public static Result success(String msg){
        return new Result(ResponseState.SUCCESS,msg);
    }

    public static Result success(Object data){
        return new Result(ResponseState.SUCCESS,ResponseMsg.SUCCESS,data);
    }

    public static Result success(String msg,Object data){
        return new Result(ResponseState.SUCCESS,msg,data);
    }

    public static Result failure(){
        return new Result(ResponseState.FAILURE,ResponseMsg.FAILURE);
    }

    public static Result failure(String msg){
        return new Result(ResponseState.FAILURE,msg);
    }

    public static Result failure(Integer state,String msg){
        return new Result(state,msg);
    }

    public static Result failure(Object data){
        return new Result(ResponseState.FAILURE,ResponseMsg.FAILURE,data);
    }

    public static Result failure(String msg,Object data){
        return new Result(ResponseState.FAILURE,msg,data);
    }
}
